<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 31.点击按钮，将列表内数字列背景色 变为红色 字母列背景变为蓝色 -->
    <span style="color:red;">31. 字列背景色变为红色字母列背景变为蓝色:</span><br/><br/>
    <table id="tab">
        <tbody>
        <tr>
           <td>333</td>
           <td>333</td>
           <td>333</td>
           <td>333</td>
        </tr>
        <tr>
          <td>aaa</td>
          <td>aaa</td>
          <td>aaa</td>
          <td>aaa</td>
        </tr>
        <tr>
         <td>666</td>
         <td>666</td>
         <td>666</td>
         <td>666</td>
        </tr>
        <tr>
            <td>啊啊啊</td>
            <td>啊啊啊</td>
            <td>啊啊啊</td>
            <td>啊啊啊</td>
         </tr>
        <tr>
           <td>bbb</td>
           <td>bbb</td>
           <td>bbb</td>
           <td>bbb</td>
        </tr>
        <tr>
            <td>啊啊啊</td>
            <td>啊啊啊</td>
            <td>啊啊啊</td>
            <td>啊啊啊</td>
         </tr>
    
    </tbody>
    </table><br/>
    <button id="btn">点击变色</button><br/><br/>
</body>
<script>
$("#btn").click(function(){
              // console.log( $("#tab tr").length)
               var reg = /^[0-9]+$/img
               var reg2 = /^[A-Za-z]+$/img
               for(var i=0;i<$("#tab tr").length;i++){
                   for(var j=0;j<$("#tab tr:eq("+i+") td").length;j++)
                    var trs=$("#tab tr:eq("+i+") td").eq(j).text()
                    console.log(trs)
                    if(reg.test(trs)==true){      
                        $("#tab tr").eq(i).css({
                            "background":"red"
                        })
                    }else if(reg2.test(trs)==true){
                        $("#tab tr").eq(i).css({
                            "background":"blue"
                        })
                    }
               }
            })


</script>
</html>